package com.km.app.controller;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: eric
 * Date: 2017-11-23
 * Time: 14:15
 */

import com.km.app.domain.R;
import com.km.app.service.CompanyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(description = "公司名称注册")
@RestController
public class CompanyController {

    private final static Log log = LogFactory.getLog(CompanyController.class);

    @Autowired
    private CompanyService companyService;

    @ApiOperation(value = "注册公司",notes = "返回的data就是您的AppId")
    @PostMapping("/company/regist")
    public R registApp(
            @ApiParam(value = "公司名称", required = true) @RequestParam(defaultValue = "") String name
    ) {
        R r = new R();
        if(StringUtils.isBlank(name)){
            return  r.fail().setMessage("公司名称不能为空");
        }
        String id = companyService.saveApp(name);
        return r.success().setData(id);
    }

}